package com.yl.ydk.ui.activity

import android.view.View
import androidx.viewpager.widget.ViewPager
import com.yl.ydk.R
import com.yl.ydk.base.BaseActivity
import com.yl.ydk.presenter.contract.HealthyVideoHomeActivityContract
import com.yl.ydk.presenter.impl.HealthyVideoHomeActivityImpl
import com.blankj.utilcode.utils.ToastUtils
import com.flyco.tablayout.SlidingTabLayout
import kotlinx.android.synthetic.main.activity_healthy_video_home.*
import kotlinx.android.synthetic.main.roob_bar.*

class HealthyVideoHomeActivity : BaseActivity(), HealthyVideoHomeActivityContract.View,
    View.OnClickListener {

    companion object {
        var healthyVideoHomeActivity: HealthyVideoHomeActivity? = null
    }

    private var mPresenter = HealthyVideoHomeActivityImpl()


    override fun getLayoutId(): Int = R.layout.activity_healthy_video_home

    override fun attachView() {
        mPresenter.attachView(this)
    }

    override fun detachView() {
        mPresenter.detachView()
    }

    override fun initView() {
        tvTitle.text = "健康讲堂"
        rlBack.setOnClickListener(this)
        mPresenter.getVideoCategories(this)
        healthyVideoHomeActivity = this
    }

    override fun onClick(v: View?) {
        when (v?.id) {
            R.id.rlBack -> {
                finish()
            }
        }
    }

    override fun onDestroy() {
        super.onDestroy()
        healthyVideoHomeActivity = null
    }

    override fun getActivity(): HealthyVideoHomeActivity = this

    override fun getSlidingTabLayout(): SlidingTabLayout? = tlPlan

    override fun getViewPager(): ViewPager? = vpPlan

    override fun showError(message: String?) {
        ToastUtils.showLongToastSafe(message)
    }

}